function myBrowser()
{
    var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
    var isOpera = userAgent.indexOf("Opera") > -1;
    if (isOpera)
    {
        return "Opera"
    }; //判断是否Opera浏览器
    if (userAgent.indexOf("Firefox") > -1)
    {
        return "FF";
    } //判断是否Firefox浏览器
    if (userAgent.indexOf("Chrome") > -1)
    {
        return "Chrome";
    }
    if (userAgent.indexOf("Safari") > -1)
    {
        return "Safari";
    } //判断是否Safari浏览器
    if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera)
    {
        return "IE";
    }; //判断是否IE浏览器

    if (!!window.ActiveXObject || "ActiveXObject" in window)
    {
        return "IE";
    }
    return "Unknown";
}
var  id_video_watch;
window.onload = function()
{
    id_video_watch = id_video_watch_v;
    fn_Start()
}
var m_IdtApi = null;
function fn_Start()
{
	if (null == m_IdtApi)
	{
        m_IdtApi = new CIdtApi();
	}
    m_IdtApi.RUN_MODE = Number("2");

    var strSrvUrl = "ws://" + '60.216.62.140' + ":10004";
    var strGpsSrvUrl = "ws://60.216.62.140:10005";
    var strUserId = "8002";
    var strPwd = "chat123*";
    var strNsUrl = "ws://60.216.62.140:10007";
    var CallBack =
    {
        // onRecvMsgHook : onRecvMsgHook,          //收到消息的钩子函数,只用来调试打印,如果修改消息内容,会出问题
        // onSendMsgHook : onSendMsgHook,          //发送消息的钩子函数,只用来调试打印,如果修改消息内容,会出问题
        // onStatusInd : onStatusInd,              //登录状态指示
        // onGInfoInd  : onGInfoInd,               //组信息指示,指示用户在哪些组里面
        // onIMRecv    : onIMRecv,                 //短信接收指示
        // onIMStatusInd : onIMStatusInd,          //短信状态指示
        // onGUOamInd  : onGUOamInd,               //用户/组OAM操作指示
        // onGUStatusInd : onGUStatusInd,          //用户/组状态指示
        // onGpsRecInd : onGpsRecInd,              //GPS数据指示
        // onGpsHisQueryInd : onGpsHisQueryInd,    //GPS历史数据查询响应
        // onCallInd   : onCallInd,                //呼叫指示
        // onNsQueryInd : onNsQueryInd             //NS查询响应
    };

    var bIsIe = false;
    if ("IE" == myBrowser())
    {
        bIsIe = true;
    }
	m_IdtApi.Start(strSrvUrl, strGpsSrvUrl, strUserId, strPwd, 1024, 32, 1, 4096, CallBack, bIsIe, strNsUrl);
}
//无人机
function fn_watch_down(strTo)
{
    var strUserMark = '';
    var ARx = Number(1);
    var ATx = Number(1);
    var VRx = Number(1);
    m_CallIdWatch = m_IdtApi.CallMakeOut(200, null, id_video_watch, ARx, ATx, VRx, 0, strTo, IDT.SRV_TYPE_WATCH_DOWN,  "", 1, 0, strUserMark);
    //m_IdtApi.CallSetPeerVolume(m_CallId, 1.0);
}

var g_ShowHB = false
function onRecvMsgHook(link, msg)
{
    if (false == g_ShowHB && msg.MsgCode == IDT.MSG_HB)
        return;

	var strOld = document.getElementById("id_rxtx_msg").value;
    var strMsg = JSON.stringify(msg);
    // \\->\
    var strMsg1 = strMsg.replace(new RegExp("\\\\\\\\", "g"), "\\");
    document.getElementById("id_rxtx_msg").value = strOld + PUtility.PGetCurTime() + " " + link + ":<--Rx--" + strMsg1 + "\r\n";
    return 0;
}
//--------------------------------------------------------------------------------
//      发送消息的钩子函数,调试用
//  输入:
//      link:           链路名
//      msg:            收到的消息
//  返回:
//      0:              成功
//      -1:             失败
//--------------------------------------------------------------------------------
function onSendMsgHook(link, msg)
{
    if (false == g_ShowHB)
    {
        if (IDT.MSG_HB == msg.MsgCode)
            return;
        if (IDT.MSG_MM_STATUSSUBS == msg.MsgCode)
        {
            if (0 == msg.MsgBody.SN)
                return;
        }
    }

	var strOld = document.getElementById("id_rxtx_msg").value;
    var strMsg = JSON.stringify(msg);
    // \\->\
    var strMsg1 = strMsg.replace(new RegExp("\\\\\\\\", "g"), "\\");
    document.getElementById("id_rxtx_msg").value = strOld + PUtility.PGetCurTime() + " " + link + ":--Tx-->" + strMsg1 + "\r\n";
    return 0;
}
